﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ESHOP.DAO;
using ESHOP.UTIL;
using ESHOP.Domain;
using E_Shop.Common;

namespace E_Shop
{
    public partial class CompanyManagerBuyLead : Authentication
    {
        private BuyLeadDAO _buyLeadDao = new BuyLeadDAO();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadDulieu();
            }
        }
        private void LoadDulieu()
        {

            var buyList = _buyLeadDao.GetBuyCompany(Acount.MACT);
            gvListBuy.DataSource = buyList;
            gvListBuy.DataBind();
            lbnumber.Text = buyList.Count().ToString();
            UpGrid.Update();
        }
        protected void gvBuy_RowCommand(object seder, GridViewCommandEventArgs e)
        {
            var buyId = e.CommandArgument.ToString();
            var objectBuy = _buyLeadDao.Get(buyId);
            var idname = e.CommandName;
            switch (idname)
            {
                case "deleteBuy":
                    {
                        _buyLeadDao.Delele(objectBuy.ID);
                        LoadDulieu();
                        UpGrid.Update();

                        break;
                    }
                case "detailBuy":
                    {
                        Response.Redirect("CompanyBuyingDetail?&id",true);
                        break;
                    }
            }
        }
        protected void gvBuy_RowDataBound(object sender, GridViewRowEventArgs e)
        {

        }

        protected void gvBuy_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {

        }
    }
}